home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWvostream.z / RWvostream
Encoding:
Text File  |  2002-10-03  |  14.3 KB  |  397 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWvostream - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/vstream.h>
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  21.      Class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm is an abstract base class.  It provides an interface for
  22.      format-independent storage of fundamental types and arrays of fundamental
  23.      types.  Its counterpart, RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm, provides a complementary interface
  24.      for the retrieval of variables of the fundamental types. Because the
  25.      interface of RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm and RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm is independent of formatting, the
  26.      user of these classes need not be concerned with how variables will
  27.      actually be stored or restored.  That will be up to the derived class to
  28.      decide.  It might be done using an operating-system independent ASCII
  29.      format (classes RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm and RRRRWWWWppppoooossssttttrrrreeeeaaaammmm), a binary format (classes
  30.      RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm and RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm), or the user could define his or her own
  31.      format (eeee....gggg...., an interface to a network).  Note that because it is an
  32.      aaaabbbbssssttttrrrraaaacccctttt base class, there is no way to actually enforce these goals --
  33.      the description here is merely the model of how a class derived from
  34.      RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm and RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm should act.  NNNNooootttteeee tttthhhhaaaatttt tttthhhheeeerrrreeee iiiissss nnnnoooo nnnneeeeeeeedddd ttttoooo
  35.      sssseeeeppppaaaarrrraaaatttteeee vvvvaaaarrrriiiiaaaabbbblllleeeessss wwwwiiiitttthhhh wwwwhhhhiiiitttteeeessssppppaaaacccceeee.  It is the responsibility of the
  36.      derived class to delineate variables with whitespace, packet breaks, or
  37.      whatever might be appropriate for the final output sink.  The model is
  38.      one where variables are inserted into the output stream, either
  39.      individually or as homogeneous vectors, to be restored in the same order
  40.      using RRRRWWWWvvvviiiissssttttrrrreeeeaaaammmm.  Storage and retrieval of characters requires some
  41.      explanation.  Characters can be thought of as either representing some
  42.      alphanumeric or control character, or as the literal number.  Generally,
  43.      the overloaded insertion (<<) and extraction (>>) operators seek to store
  44.      and restore characters preserving their symbolic meaning.  That is,
  45.      storage of a newline should be restored as a newline, regardless of its
  46.      representation on the target machine.  By contrast, member functions
  47.      ggggeeeetttt(((()))) and ppppuuuutttt(((()))) should treat the character as a literal number, whose
  48.      value is to be preserved.  See also class RRRRWWWWppppoooossssttttrrrreeeeaaaammmm.
  49.  
  50. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  51.      None
  52.  
  53. EEEExxxxaaaammmmpppplllleeee
  54.               #include <rw/vstream.h>
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.               void storeStuff( RWvostream& str) {
  75.              int i = 5;
  76.              double d = 22.5;
  77.              char string[] = "A string with  tabs and a newline0;
  78.              str << i;        // Store an int
  79.              str << d;        // Store a double
  80.              str << string;   // Store a string
  81.              if(str.fail()) cerr << "Oh, oh, bad news.0;
  82.           }
  83.  
  84. PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr
  85.               virtual ~~~~RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm(((())));
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.      This virtual destructor allows specializing classes to deallocate any
  93.      resources that they may have allocated.
  94.  
  95. PPPPuuuubbbblllliiiicccc OOOOppppeeeerrrraaaattttoooorrrrssss
  96.               virtual RWvostream&
  97.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(const char* s) = 0;
  98.  
  99.  
  100.      Store the character string starting at ssss to the output stream.  The
  101.      character string is expected to be null terminated.
  102.  
  103.               virtual RWvostream&
  104.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(const wchar_t* ws) = 0;
  105.  
  106.  
  107.      Store the wide character string starting at wwwwssss to the output stream.  The
  108.      character string is expected to be null terminated.
  109.  
  110.               virtual RWvostream&
  111.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(char c) = 0;
  112.  
  113.  
  114.      Store the cccchhhhaaaarrrr cccc to the output stream.  Note that cccc is treated as a
  115.      character, not a number.
  116.  
  117.               virtual RWvostream&
  118.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(wchar_t wc) = 0;
  119.  
  120.  
  121.      Store the wwwwcccchhhhaaaarrrr____tttt wwwwcccc to the output stream.  Note that wwwwcccc is treated as a
  122.      character, not a number.
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.               virtual RWvostream&
  141.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned char c) = 0;
  142.  
  143.  
  144.      Store the uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr cccc to the output stream.  Note that cccc is treated
  145.      as a character, not a number.
  146.  
  147.               virtual RWvostream&
  148.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(double d) = 0;
  149.  
  150.  
  151.      Store the ddddoooouuuubbbblllleeee dddd to the output stream.
  152.  
  153.               virtual RWvostream&
  154.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(float f) = 0;
  155.  
  156.  
  157.      Store the ffffllllooooaaaatttt ffff to the output stream.
  158.  
  159.               virtual RWvostream&
  160.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(int i) = 0;
  161.  
  162.  
  163.      Store the iiiinnnntttt iiii to the output stream.
  164.  
  165.               virtual RWvostream&
  166.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned int i) = 0;
  167.  
  168.  
  169.      Store the uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt iiii to the output stream.
  170.  
  171.               virtual RWvostream&
  172.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(long l) = 0;
  173.  
  174.  
  175.      Store the lllloooonnnngggg llll to the output stream.
  176.  
  177.               virtual RWvostream&
  178.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned long l) = 0;
  179.  
  180.  
  181.      Store the uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg llll to the output stream.
  182.  
  183.               virtual RWvostream&
  184.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(short s) = 0;
  185.  
  186.  
  187.      Store the sssshhhhoooorrrrtttt ssss to the output stream.
  188.  
  189.               virtual RWvostream&
  190.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned short s) = 0;
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Store the uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt ssss to the output stream.
  207.  
  208.               ooooppppeeeerrrraaaattttoooorrrr vvvvooooiiiidddd****();
  209.  
  210.  
  211.      Inherited from RRRRWWWWvvvviiiioooossss.
  212.  
  213. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  214.               virtual RWvostream&
  215.           fffflllluuuusssshhhh();
  216.  
  217.  
  218.      Send the contents of the stream buffer to output immediately.
  219.  
  220.               virtual RWvostream&
  221.           ppppuuuutttt(char c) = 0;
  222.  
  223.  
  224.      Store the cccchhhhaaaarrrr cccc to the output stream, preserving its value.
  225.  
  226.               virtual RWvostream&
  227.           ppppuuuutttt(wchar_t wc) = 0;
  228.  
  229.  
  230.      Store the wwwwcccchhhhaaaarrrr____tttt wwwwcccc to the output stream, preserving its value.
  231.  
  232.               virtual RWvostream&
  233.           ppppuuuutttt(unsigned char c) = 0;
  234.  
  235.  
  236.      Store the cccchhhhaaaarrrr cccc to the output stream, preserving its value.
  237.  
  238.               virtual RWvostream&
  239.           ppppuuuutttt(const char* p, size_t N) = 0;
  240.  
  241.  
  242.      Store the vector of NNNN cccchhhhaaaarrrrs starting at pppp to the output stream.  The
  243.      chars should be treated as literal numbers (iiii....eeee...., not as a character
  244.      string).
  245.  
  246.               virtual RWvostream&
  247.           ppppuuuutttt(const wchar_t* p, size_t N) = 0;
  248.  
  249.  
  250.      Store the vector of NNNN wwwwcccchhhhaaaarrrr____tttts starting at pppp to the output stream.  The
  251.      chars should be treated as literal numbers (iiii....eeee...., not as a character
  252.      string).
  253.  
  254.               virtual RWvostream&
  255.           ppppuuuutttt(const unsigned char* p, size_t N) = 0;
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.      Store the vector of NNNN uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrrs starting at pppp to the output stream.
  273.      The chars should be treated as literal numbers (i.e., not as a character
  274.      string).
  275.  
  276.               virtual RWvostream&
  277.           ppppuuuutttt(const short* p, size_t N) = 0;
  278.  
  279.  
  280.      Store the vector of NNNN sssshhhhoooorrrrtttts starting at pppp to the output stream.
  281.  
  282.               virtual RWvostream&
  283.           ppppuuuutttt(const unsigned short* p, size_t N) = 0;
  284.  
  285.  
  286.      Store the vector of NNNN uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttts starting at pppp to the output stream.
  287.  
  288.               virtual RWvostream&
  289.           ppppuuuutttt(const int* p, size_t N) = 0;
  290.  
  291.  
  292.      Store the vector of NNNN iiiinnnntttts starting at pppp to the output stream.
  293.  
  294.               virtual RWvostream&
  295.           ppppuuuutttt(const unsigned int* p, size_t N) = 0;
  296.  
  297.  
  298.      Store the vector of NNNN uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttts starting at pppp to the output stream.
  299.  
  300.               virtual RWvostream&
  301.           ppppuuuutttt(const long* p, size_t N) = 0;
  302.  
  303.  
  304.      Store the vector of NNNN lllloooonnnnggggs starting at pppp to the output stream.
  305.  
  306.               virtual RWvostream&
  307.           ppppuuuutttt(const unsigned long* p, size_t N) = 0;
  308.  
  309.  
  310.      Store the vector of NNNN uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnnggggs starting at pppp to the output stream.
  311.  
  312.               virtual RWvostream&
  313.           ppppuuuutttt(const float* p, size_t N) = 0;
  314.  
  315.  
  316.      Store the vector of NNNN ffffllllooooaaaatttts starting at pppp to the output stream.
  317.  
  318.               virtual RWvostream&
  319.           ppppuuuutttt(const double* p, size_t N) = 0;
  320.  
  321.  
  322.      Store the vector of NNNN ddddoooouuuubbbblllleeees starting at pppp to the output stream.
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.               virtual RWvostream&
  339.           ppppuuuuttttSSSSttttrrrriiiinnnngggg(const char*s, size_t N);
  340.  
  341.  
  342.      Store the character string, iiiinnnncccclllluuuuddddiiiinnnngggg eeeemmmmbbbbeeeeddddddddeeeedddd nnnnuuuullllllllssss, starting at s to
  343.      the output string.
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.